package test.yunpay.com.mvpproject.viewImpl;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

import butterknife.OnClick;
import test.yunpay.com.mvpproject.BaseActivity;
import test.yunpay.com.mvpproject.R;
import test.yunpay.com.mvpproject.presenter.IBasePresenter;
import test.yunpay.com.mvpproject.presenter.IMainPresenter;
import test.yunpay.com.mvpproject.presenterImpl.MainPresenterImpl;
import test.yunpay.com.mvpproject.util.LogUtil;
import test.yunpay.com.mvpproject.util.ToastUtil;
import test.yunpay.com.mvpproject.view.IMainView;

/**
 * @Author sjt
 * @Date 2018/5/4 0004
 * @description MVP中的view层 负责view 的显示
 */
public class MainActivity extends BaseActivity implements IMainView {
    private IMainPresenter mainPresenter;

    @Override
    public int getLayoutResId() {
        return R.layout.activity_main;
    }

    @Override
    public void initView() {
        findViewById(R.id.click).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mainPresenter.showResult();
            }
        });
    }

    @Override
    public void initData() {
        mainPresenter = new MainPresenterImpl(this);
    }

    @Override
    protected IBasePresenter bindPresenter() {
        return mainPresenter;
    }

    @Override
    public void showToast(String s) {
        LogUtil.e("MainActivity--showToast");
        ToastUtil.showToastShort(this, s);
    }

}
